// pages/my/my.js
var app = getApp();
Page({
  data: {
    shipHidden: true,
    receiptHidden: true,
    valueHidden: true,
    afterSaleHidden: true,
    isOpenShop:true,
    tabLists:[
      {
        name: '快送预约订单',
        url: 'kuaisongyuyuedingdan@2x',
        navUrl: "fastSendOrder",
      },
      {
        name: '快送购物车',
        url: 'putaojiufenji@2x',
        navUrl: "fastSendCart",
      },

      {
        name: '跨境进货订单',
        url: 'jinhuodingdan@2x',
        navUrl: "crossOrder",
      },
      {
        name: '跨境购收货地址管理',
        url: 'shouhuodizhi@2x',
        navUrl: "directAddress",
      },
      {
        name: '跨境购物车',
        url: 'gouwuche@2x',
        navUrl: "directBuy",
      },
      {
        name: '分销与积分',
        url: 'wodefenxiao@2x',
        navUrl: "myAddCode",
      },
      {
        name: '德国禾怡伯格酒庄介绍',
        url: 'jieshao@2x',
        navUrl: "wineryInfo",
      },
      {
        name: '小程序使用说明',
        url: 'shiyongshuoming@2x',
        navUrl: "infoUse",
      },
    ]  
  },
  onShareAppMessage: function (res) {
    return {
      title: 'DaisyColor黛颜',
      path: '/pages/direct/direct?id=' + wx.getStorageSync("userid"),
    }
  },
  onLoad: function (options) {
    app.showShareMenus();
    if (options.id){
      app.globalData.referrerId = options.id
   }
    var pages2 = getCurrentPages()    //获取加载的页面
    var currentPage = pages2[pages2.length - 1]    //获取当前页面的对象
    //var url = currentPage.route    //当前页面url
    var sss = currentPage.route.split("pages/")[1]
    var bbb=sss.split("/")[0]
    var that = this
    wx.getSystemInfo({//获取滑块的高宽
      success: function (res) {
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight,
          uuid:wx.getStorageSync("userid")
        });
      }
    });
  },
   getcds:function(ss){
  
   }
  ,
   
  onReady: function () {
    // 页面渲染完成
  },

  onShow: function () {
    // 页面显示
    this.setData({
      userInfo: wx.getStorageSync('userInfo'),
      code: wx.getStorageSync('code'),
      uuid: wx.getStorageSync('userid'),
    });
    this.setData({
      shipHidden: true,
      receiptHidden: true,
      valueHidden: true,
      afterSaleHidden: true
    })
    var that = this;
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  },
  spikeGroup: function () {
    wx.navigateTo({
      url: '../ticket/ticket',
      success: function (res) {
        // success
      }
    })
  },
  wxPay:function(){
    wx.navigateTo({
      url: '../Recharge/Recharge',  
    })
  },
  chooseAddress: function () {
    wx.navigateTo({
      url: '/pages/directAddress/directAddress?click=1',
      success: function(res){
        // success
      },
      fail: function(res) {
        // fail
      },
      complete: function(res) {
        // complete
      }
    })
    // if (wx.chooseAddress) {
    //   　　wx.chooseAddress({
    //     　　success: function (res) {
    //       　　console.log(JSON.stringify(res))
    //     　　},
    //     　　fail: function (err) {
    //       　　console.log(JSON.stringify(err))
    //     　　}
    //   　　})
    // 　　} else {
    //   　　wx.shouToast({
    //     title: '您的微信版本较低，无法使用微信地址，建议下载最新版本',
    //     icon: 'loading',
    //     duration: 2000
    //   })
    // 　　}
  }
  ,
  myDistribution:function(){//我的分销
    wx.navigateTo({
      url: '/pages/Distribution/Distribution',
    })
  }, aboutUs:function(){
    wx.navigateTo({
      url: '/pages/index/index',
    })
  },formSubmit:function(e){
    wx.showModal({
      title: e.detail.formId+"",
      content: '',
    })
    // wx.request({
    //   url: ,
    //   data: {

    //   "form_id":  e.detail.formId
    //   }
     
    // })
  },
  switchChange:function(e){
    var that=this;
    if(e.detail.value){
      wx.showModal({
        title: '提示',
        content: '开启快送预约',
        success: function (res) {
          if (res.confirm) {
            that.setData({
              isOpenShop:true
            })
          } else if (res.cancel) {
            that.setData({
              isOpenShop: false
            })
          }
        }
      })
    }else{
      wx.showModal({
        title: '提示',
        content: '关闭快送预约',
        success: function (res) {
          if (res.confirm) {
            that.setData({
              isOpenShop: false
            })
          } else if (res.cancel) {
            that.setData({
              isOpenShop: true
            })
          }
        }
      })
    }
  }
})
